package com.lzm.back.exception;

import com.lzm.back.common.MyResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice("com.lzm.back.controller")
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public MyResult error(Exception e) {
        e.printStackTrace();
        return MyResult.error();
    }


    @ExceptionHandler(CustomeException.class)
    @ResponseBody
    public MyResult error(CustomeException e) {

        return MyResult.error(e.getNode(), e.getMsg());
    }

}
